e_type_dit = {
    0: "ET_NONE",
    1: "ET_REL",
    2: "ET_EXEC",
    3: "ET_DYN",
    4: "ET_CORE",
    5: "ET_NUM",
    0xfe00: "ET_LOOS",
    0xfeff: "ET_HIOS",
    0xff00: "ET_LOPROC",
    0xffff: "ET_HIPROC",
}
e_machine_dit = {
    0: "EM_NONE",
    1: "EM_M32",
    2: "EM_SPARC",
    3: "EM_386",
    4: "EM_68K",
    5: "EM_88K",
    7: "EM_860",
    8: "EM_MIPS",
    9: "EM_S370",
    10: "EM_MIPS_RS3_LE",
    15: "EM_PARISC",
    17: "EM_VPP500",
    18: "EM_SPARC32PLUS",
    19: "EM_960",
    20: "EM_PPC",
    21: "EM_PPC64",
    22: "EM_S390",
    36: "EM_V800",
    37: "EM_FR20",
    38: "EM_RH32",
    39: "EM_RCE",
    40: "EM_ARM",
    41: "EM_FAKE_ALPHA",
    42: "EM_SH",
    43: "EM_SPARCV9",
    44: "EM_TRICORE",
    45: "EM_ARC",
    46: "EM_H8_300",
    47: "EM_H8_300H",
    48: "EM_H8S",
    49: "EM_H8_500",
    50: "EM_IA_64",
    51: "EM_MIPS_X",
    52: "EM_COLDFIRE",
    53: "EM_68HC12",
    54: "EM_MMA",
    55: "EM_PCP",
    56: "EM_NCPU",
    57: "EM_NDR1",
    58: "EM_STARCORE",
    59: "EM_ME16",
    60: "EM_ST100",
    61: "EM_TINYJ",
    62: "EM_X86_64",
    63: "EM_PDSP",
    66: "EM_FX66",
    67: "EM_ST9PLUS",
    68: "EM_ST7",
    69: "EM_68HC16",
    70: "EM_68HC11",
    71: "EM_68HC08",
    72: "EM_68HC05",
    73: "EM_SVX",
    74: "EM_ST19",
    75: "EM_VAX",
    76: "EM_CRIS",
    77: "EM_JAVELIN",
    78: "EM_FIREPATH",
    79: "EM_ZSP",
    80: "EM_MMIX",
    81: "EM_HUANY",
    82: "EM_PRISM",
    83: "EM_AVR",
    84: "EM_FR30",
    85: "EM_D10V",
    86: "EM_D30V",
    87: "EM_V850",
    88: "EM_M32R",
    89: "EM_MN10300",
    90: "EM_MN10200",
    91: "EM_PJ",
    92: "EM_OPENRISC",
    93: "EM_ARC_A5",
    94: "EM_XTENSA",
    113: "EM_ALTERA_NIOS2",
    183: "EM_AARCH64",
    188: "EM_TILEPRO",
    189: "EM_MICROBLAZE",
    191: "EM_TILEGX",
    192: "EM_NUM",
    0x9026: "EM_ALPHA",

}
e_os_abi_dit = {
    0: "ELFOSABI_NONE",
    1: "ELFOSABI_HPUX",
    2: "ELFOSABI_NETBSD",
    3: "ELFOSABI_LINUX",
    6: "ELFOSABI_SOLARIS",
    7: "ELFOSABI_AIX",
    8: "ELFOSABI_IRIX",
    9: "ELFOSABI_FREEBSD",
    10: "ELFOSABI_TRU64",
    11: "ELFOSABI_MODESTO",
    12: "ELFOSABI_OPENBSD",
    64: "ELFOSABI_ARM_AEABI",
    97: "ELFOSABI_ARM",
    255: "ELFOSABI_STANDALONE",
}
e_flags = {
    "	EF_SPARCV9_MM	": 3,
    "	EF_SPARCV9_TSO	": 0,
    "	EF_SPARCV9_PSO	": 1,
    "	EF_SPARCV9_RMO	": 2,
    "	EF_SPARC_LEDATA	": 0x800000,
    "	EF_SPARC_EXT_MASK	": 0xFFFF00,
    "	EF_SPARC_32PLUS	": 0x000100,
    "	EF_SPARC_SUN_US1	": 0x000200,
    "	EF_SPARC_HAL_R1	": 0x000400,
    "	EF_SPARC_SUN_US3	": 0x000800,
    "	EF_MIPS_NOREORDER	": 1,
    "	EF_MIPS_PIC	": 2,
    "	EF_MIPS_CPIC	": 4,
    "	EF_MIPS_XGOT	": 8,
    "	EF_MIPS_64BIT_WHIRL	": 16,
    "	EF_MIPS_ABI2	": 32,
    "	EF_MIPS_ABI_ON32	": 64,
    "	EF_MIPS_FP64	": 512,
    "	EF_MIPS_NAN2008	": 1024,
    "	EF_MIPS_ARCH	": 0xf0000000,
    "	EF_MIPS_ARCH_1	": 0x00000000,
    "	EF_MIPS_ARCH_2	": 0x10000000,
    "	EF_MIPS_ARCH_3	": 0x20000000,
    "	EF_MIPS_ARCH_4	": 0x30000000,
    "	EF_MIPS_ARCH_5	": 0x40000000,
    "	EF_MIPS_ARCH_32	": 0x50000000,
    "	EF_MIPS_ARCH_64	": 0x60000000,
    "	EF_MIPS_ARCH_32R2	": 0x70000000,
    "	EF_MIPS_ARCH_64R2	": 0x80000000,

}

section_indices_dit = {
    "	SHN_UNDEF	": 0,
    "	SHN_LORESERVE	": 0xff00,
    "	SHN_LOPROC	": 0xff00,
    "	SHN_BEFORE	": 0xff00,
    "	SHN_AFTER	": 0xff01,
    "	SHN_HIPROC	": 0xff1f,
    "	SHN_LOOS	": 0xff20,
    "	SHN_HIOS	": 0xff3f,
    "	SHN_ABS	": 0xfff1,
    "	SHN_COMMON	": 0xfff2,
    "	SHN_XINDEX	": 0xffff,
    "	SHN_HIRESERVE	": 0xffff,
    "	SHN_MIPS_ACOMMON	": 0xff00,
    "	SHN_MIPS_TEXT	": 0xff01,
    "	SHN_MIPS_DATA	": 0xff02,
    "	SHN_MIPS_SCOMMON	": 0xff03,
    "	SHN_MIPS_SUNDEFINED	": 0xff04,

}

section_type_dit = {
    "	SHT_NULL	": 0,
    "	SHT_PROGBITS	": 1,
    "	SHT_SYMTAB	": 2,
    "	SHT_STRTAB	": 3,
    "	SHT_RELA	": 4,
    "	SHT_HASH	": 5,
    "	SHT_DYNAMIC	": 6,
    "	SHT_NOTE	": 7,
    "	SHT_NOBITS	": 8,
    "	SHT_REL	": 9,
    "	SHT_SHLIB	": 10,
    "	SHT_DYNSYM	": 11,
    "	SHT_INIT_ARRAY	": 14,
    "	SHT_FINI_ARRAY	": 15,
    "	SHT_PREINIT_ARRAY	": 16,
    "	SHT_GROUP	": 17,
    "	SHT_SYMTAB_SHNDX	": 18,
    "	SHT_NUM	": 19,
    "	SHT_LOOS	": 0x60000000,
    "	SHT_GNU_ATTRIBUTES	": 0x6ffffff5,
    "	SHT_GNU_HASH	": 0x6ffffff6,
    "	SHT_GNU_LIBLIST	": 0x6ffffff7,
    "	SHT_CHECKSUM	": 0x6ffffff8,
    "	SHT_LOSUNW	": 0x6ffffffa,
    "	SHT_SUNW_move	": 0x6ffffffa,
    "	SHT_SUNW_COMDAT	": 0x6ffffffb,
    "	SHT_SUNW_syminfo	": 0x6ffffffc,
    "	SHT_GNU_verdef	": 0x6ffffffd,
    "	SHT_GNU_verneed	": 0x6ffffffe,
    "	SHT_GNU_versym	": 0x6fffffff,
    "	SHT_HISUNW	": 0x6fffffff,
    "	SHT_HIOS	": 0x6fffffff,
    "	SHT_LOPROC	": 0x70000000,
    "	SHT_HIPROC	": 0x7fffffff,
    "	SHT_LOUSER	": 0x80000000,
    "	SHT_HIUSER	": 0x8fffffff,
    "	SHT_MIPS_LIBLIST	": 0x70000000,
    "	SHT_MIPS_MSYM	": 0x70000001,
    "	SHT_MIPS_CONFLICT	": 0x70000002,
    "	SHT_MIPS_GPTAB	": 0x70000003,
    "	SHT_MIPS_UCODE	": 0x70000004,
    "	SHT_MIPS_DEBUG	": 0x70000005,
    "	SHT_MIPS_REGINFO	": 0x70000006,
    "	SHT_MIPS_PACKAGE	": 0x70000007,
    "	SHT_MIPS_PACKSYM	": 0x70000008,
    "	SHT_MIPS_RELD	": 0x70000009,
    "	SHT_MIPS_IFACE	": 0x7000000b,
    "	SHT_MIPS_CONTENT	": 0x7000000c,
    "	SHT_MIPS_OPTIONS	": 0x7000000d,
    "	SHT_MIPS_SHDR	": 0x70000010,
    "	SHT_MIPS_FDESC	": 0x70000011,
    "	SHT_MIPS_EXTSYM	": 0x70000012,
    "	SHT_MIPS_DENSE	": 0x70000013,
    "	SHT_MIPS_PDESC	": 0x70000014,
    "	SHT_MIPS_LOCSYM	": 0x70000015,
    "	SHT_MIPS_AUXSYM	": 0x70000016,
    "	SHT_MIPS_OPTSYM	": 0x70000017,
    "	SHT_MIPS_LOCSTR	": 0x70000018,
    "	SHT_MIPS_LINE	": 0x70000019,
    "	SHT_MIPS_RFDESC	": 0x7000001a,
    "	SHT_MIPS_DELTASYM	": 0x7000001b,
    "	SHT_MIPS_DELTAINST	": 0x7000001c,
    "	SHT_MIPS_DELTACLASS	": 0x7000001d,
    "	SHT_MIPS_DWARF	": 0x7000001e,
    "	SHT_MIPS_DELTADECL	": 0x7000001f,
    "	SHT_MIPS_SYMBOL_LIB	": 0x70000020,
    "	SHT_MIPS_EVENTS	": 0x70000021,
    "	SHT_MIPS_TRANSLATE	": 0x70000022,
    "	SHT_MIPS_PIXIE	": 0x70000023,
    "	SHT_MIPS_XLATE	": 0x70000024,
    "	SHT_MIPS_XLATE_DEBUG	": 0x70000025,
    "	SHT_MIPS_WHIRL	": 0x70000026,
    "	SHT_MIPS_EH_REGION	": 0x70000027,
    "	SHT_MIPS_XLATE_OLD	": 0x70000028,
    "	SHT_MIPS_PDR_EXCEPTION	": 0x70000029,

}
section_flags_dit = {
    "	SHF_WRITE	": 1 << 0,
    "	SHF_ALLOC	": 1 << 1,
    "	SHF_EXECINSTR	": 1 << 2,
    "	SHF_MERGE	": 1 << 4,
    "	SHF_STRINGS	": 1 << 5,
    "	SHF_INFO_LINK	": 1 << 6,
    "	SHF_LINK_ORDER	": 1 << 7,
    "	SHF_OS_NONCONFORMING	": 1 << 8,
    "	SHF_GROUP	": 1 << 9,
    "	SHF_TLS	": 1 << 10,
    "	SHF_COMPRESSED	": 1 << 11,
    "	SHF_MASKOS	": 0x0ff00000,
    "	SHF_MASKPROC	": 0xf0000000,
    "	SHF_ORDERED	": 1 << 30,
    "	SHF_EXCLUDE	": 256 << 31,
    "	SHF_MIPS_GPREL	": 0x10000000,
    "	SHF_MIPS_MERGE	": 0x20000000,
    "	SHF_MIPS_ADDR	": 0x40000000,
    "	SHF_MIPS_STRINGS	": 0x80000000,
    "	SHF_MIPS_NOSTRIP	": 0x08000000,
    "	SHF_MIPS_LOCAL	": 0x04000000,
    "	SHF_MIPS_NAMES	": 0x02000000,
    "	SHF_MIPS_NODUPE	": 0x01000000,

}
compression_algorithm_dit = {
    "	ELFCOMPRESS_ZLIB	": 1,
    "	ELFCOMPRESS_LOOS	": 0x60000000,
    "	ELFCOMPRESS_HIOS	": 0x6fffffff,
    "	ELFCOMPRESS_LOPROC	": 0x70000000,
    "	ELFCOMPRESS_HIPROC	": 0x7fffffff,
}
symbol_bound = {
    "	SYMINFO_BT_SELF	": 0xffff,
    "	SYMINFO_BT_PARENT	": 0xfffe,
    "	SYMINFO_BT_LOWRESERVE	": 0xff00,

}

symbol_flag_dit = {
    "	SYMINFO_FLG_DIRECT	": 0x0001,
    "	SYMINFO_FLG_PASSTHRU	": 0x0002,
    "	SYMINFO_FLG_COPY	": 0x0004,
    "	SYMINFO_FLG_LAZYLOAD	": 0x0008,

}

syminfo_version = {
    "	SYMINFO_NONE	": 0,
    "	SYMINFO_CURRENT	": 1,
    "	SYMINFO_NUM	": 2,

}

syminfo_table_info = {
    "	STB_LOCAL	": 0,
    "	STB_GLOBAL	": 1,
    "	STB_WEAK	": 2,
    "	STB_NUM	": 3,
    "	STB_LOOS	": 10,
    "	STB_GNU_UNIQUE	": 10,
    "	STB_HIOS	": 12,
    "	STB_LOPROC	": 13,
    "	STB_HIPROC	": 15,

}

syminfo_table_type = {
    "	STT_NOTYPE	": 0,
    "	STT_OBJECT	": 1,
    "	STT_FUNC	": 2,
    "	STT_SECTION	": 3,
    "	STT_FILE	": 4,
    "	STT_COMMON	": 5,
    "	STT_TLS	": 6,
    "	STT_NUM	": 7,
    "	STT_LOOS	": 10,
    "	STT_GNU_IFUNC	": 10,
    "	STT_HIOS	": 12,
    "	STT_LOPROC	": 13,
    "	STT_HIPROC	": 15,
    "	STN_UNDEF	": 0,

}

syminfo_table_other = {
    "	STV_DEFAULT	": 0,
    "	STV_INTERNAL	": 1,
    "	STV_HIDDEN	": 2,
    "	STV_PROTECTED	": 3,
    "	STO_MIPS_DEFAULT	": 0x0,
    "	STO_MIPS_INTERNAL	": 0x1,
    "	STO_MIPS_HIDDEN	": 0x2,
    "	STO_MIPS_PROTECTED	": 0x3,
    "	STO_MIPS_PLT	": 0x8,
    "	STO_MIPS_SC_ALIGN_UNUSED	": 0xff,

}

relocat_table_type = {
    "	R_68K_NONE	": 0,
    "	R_68K_32	": 1,
    "	R_68K_16	": 2,
    "	R_68K_8	": 3,
    "	R_68K_PC32	": 4,
    "	R_68K_PC16	": 5,
    "	R_68K_PC8	": 6,
    "	R_68K_GOT32	": 7,
    "	R_68K_GOT16	": 8,
    "	R_68K_GOT8	": 9,
    "	R_68K_GOT32O	": 10,
    "	R_68K_GOT16O	": 11,
    "	R_68K_GOT8O	": 12,
    "	R_68K_PLT32	": 13,
    "	R_68K_PLT16	": 14,
    "	R_68K_PLT8	": 15,
    "	R_68K_PLT32O	": 16,
    "	R_68K_PLT16O	": 17,
    "	R_68K_PLT8O	": 18,
    "	R_68K_COPY	": 19,
    "	R_68K_GLOB_DAT	": 20,
    "	R_68K_JMP_SLOT	": 21,
    "	R_68K_RELATIVE	": 22,
    "	R_68K_TLS_GD32	": 25,
    "	R_68K_TLS_GD16	": 26,
    "	R_68K_TLS_GD8	": 27,
    "	R_68K_TLS_LDM32	": 28,
    "	R_68K_TLS_LDM16	": 29,
    "	R_68K_TLS_LDM8	": 30,
    "	R_68K_TLS_LDO32	": 31,
    "	R_68K_TLS_LDO16	": 32,
    "	R_68K_TLS_LDO8	": 33,
    "	R_68K_TLS_IE32	": 34,
    "	R_68K_TLS_IE16	": 35,
    "	R_68K_TLS_IE8	": 36,
    "	R_68K_TLS_LE32	": 37,
    "	R_68K_TLS_LE16	": 38,
    "	R_68K_TLS_LE8	": 39,
    "	R_68K_TLS_DTPMOD32	": 40,
    "	R_68K_TLS_DTPREL32	": 41,
    "	R_68K_TLS_TPREL32	": 42,
    "	R_68K_NUM	": 43,
    "	R_386_NONE	": 0,
    "	R_386_32	": 1,
    "	R_386_PC32	": 2,
    "	R_386_GOT32	": 3,
    "	R_386_PLT32	": 4,
    "	R_386_COPY	": 5,
    "	R_386_GLOB_DAT	": 6,
    "	R_386_JMP_SLOT	": 7,
    "	R_386_RELATIVE	": 8,
    "	R_386_GOTOFF	": 9,
    "	R_386_GOTPC	": 10,
    "	R_386_32PLT	": 11,
    "	R_386_TLS_TPOFF	": 14,
    "	R_386_TLS_IE	": 15,
    "	R_386_TLS_GOTIE	": 16,
    "	R_386_TLS_LE	": 17,
    "	R_386_TLS_GD	": 18,
    "	R_386_TLS_LDM	": 19,
    "	R_386_16	": 20,
    "	R_386_PC16	": 21,
    "	R_386_8	": 22,
    "	R_386_PC8	": 23,
    "	R_386_TLS_GD_32	": 24,
    "	R_386_TLS_GD_PUSH	": 25,
    "	R_386_TLS_GD_CALL	": 26,
    "	R_386_TLS_GD_POP	": 27,
    "	R_386_TLS_LDM_32	": 28,
    "	R_386_TLS_LDM_PUSH	": 29,
    "	R_386_TLS_LDM_CALL	": 30,
    "	R_386_TLS_LDM_POP	": 31,
    "	R_386_TLS_LDO_32	": 32,
    "	R_386_TLS_IE_32	": 33,
    "	R_386_TLS_LE_32	": 34,
    "	R_386_TLS_DTPMOD32	": 35,
    "	R_386_TLS_DTPOFF32	": 36,
    "	R_386_TLS_TPOFF32	": 37,
    "	R_386_SIZE32	": 38,
    "	R_386_TLS_GOTDESC	": 39,
    "	R_386_TLS_DESC_CALL	": 40,
    "	R_386_TLS_DESC	": 41,
    "	R_386_IRELATIVE	": 42,
    "	R_386_NUM	": 43,
    "	R_SPARC_NONE	": 0,
    "	R_SPARC_8	": 1,
    "	R_SPARC_16	": 2,
    "	R_SPARC_32	": 3,
    "	R_SPARC_DISP8	": 4,
    "	R_SPARC_DISP16	": 5,
    "	R_SPARC_DISP32	": 6,
    "	R_SPARC_WDISP30	": 7,
    "	R_SPARC_WDISP22	": 8,
    "	R_SPARC_HI22	": 9,
    "	R_SPARC_22	": 10,
    "	R_SPARC_13	": 11,
    "	R_SPARC_LO10	": 12,
    "	R_SPARC_GOT10	": 13,
    "	R_SPARC_GOT13	": 14,
    "	R_SPARC_GOT22	": 15,
    "	R_SPARC_PC10	": 16,
    "	R_SPARC_PC22	": 17,
    "	R_SPARC_WPLT30	": 18,
    "	R_SPARC_COPY	": 19,
    "	R_SPARC_GLOB_DAT	": 20,
    "	R_SPARC_JMP_SLOT	": 21,
    "	R_SPARC_RELATIVE	": 22,
    "	R_SPARC_UA32	": 23,
    "	R_SPARC_PLT32	": 24,
    "	R_SPARC_HIPLT22	": 25,
    "	R_SPARC_LOPLT10	": 26,
    "	R_SPARC_PCPLT32	": 27,
    "	R_SPARC_PCPLT22	": 28,
    "	R_SPARC_PCPLT10	": 29,
    "	R_SPARC_10	": 30,
    "	R_SPARC_11	": 31,
    "	R_SPARC_64	": 32,
    "	R_SPARC_OLO10	": 33,
    "	R_SPARC_HH22	": 34,
    "	R_SPARC_HM10	": 35,
    "	R_SPARC_LM22	": 36,
    "	R_SPARC_PC_HH22	": 37,
    "	R_SPARC_PC_HM10	": 38,
    "	R_SPARC_PC_LM22	": 39,
    "	R_SPARC_WDISP16	": 40,
    "	R_SPARC_WDISP19	": 41,
    "	R_SPARC_GLOB_JMP	": 42,
    "	R_SPARC_7	": 43,
    "	R_SPARC_5	": 44,
    "	R_SPARC_6	": 45,
    "	R_SPARC_DISP64	": 46,
    "	R_SPARC_PLT64	": 47,
    "	R_SPARC_HIX22	": 48,
    "	R_SPARC_LOX10	": 49,
    "	R_SPARC_H44	": 50,
    "	R_SPARC_M44	": 51,
    "	R_SPARC_L44	": 52,
    "	R_SPARC_REGISTER	": 53,
    "	R_SPARC_UA64	": 54,
    "	R_SPARC_UA16	": 55,
    "	R_SPARC_TLS_GD_HI22	": 56,
    "	R_SPARC_TLS_GD_LO10	": 57,
    "	R_SPARC_TLS_GD_ADD	": 58,
    "	R_SPARC_TLS_GD_CALL	": 59,
    "	R_SPARC_TLS_LDM_HI22	": 60,
    "	R_SPARC_TLS_LDM_LO10	": 61,
    "	R_SPARC_TLS_LDM_ADD	": 62,
    "	R_SPARC_TLS_LDM_CALL	": 63,
    "	R_SPARC_TLS_LDO_HIX22	": 64,
    "	R_SPARC_TLS_LDO_LOX10	": 65,
    "	R_SPARC_TLS_LDO_ADD	": 66,
    "	R_SPARC_TLS_IE_HI22	": 67,
    "	R_SPARC_TLS_IE_LO10	": 68,
    "	R_SPARC_TLS_IE_LD	": 69,
    "	R_SPARC_TLS_IE_LDX	": 70,
    "	R_SPARC_TLS_IE_ADD	": 71,
    "	R_SPARC_TLS_LE_HIX22	": 72,
    "	R_SPARC_TLS_LE_LOX10	": 73,
    "	R_SPARC_TLS_DTPMOD32	": 74,
    "	R_SPARC_TLS_DTPMOD64	": 75,
    "	R_SPARC_TLS_DTPOFF32	": 76,
    "	R_SPARC_TLS_DTPOFF64	": 77,
    "	R_SPARC_TLS_TPOFF32	": 78,
    "	R_SPARC_TLS_TPOFF64	": 79,
    "	R_SPARC_GOTDATA_HIX22	": 80,
    "	R_SPARC_GOTDATA_LOX10	": 81,
    "	R_SPARC_GOTDATA_OP_HIX22	": 82,
    "	R_SPARC_GOTDATA_OP_LOX10	": 83,
    "	R_SPARC_GOTDATA_OP	": 84,
    "	R_SPARC_H34	": 85,
    "	R_SPARC_SIZE32	": 86,
    "	R_SPARC_SIZE64	": 87,
    "	R_SPARC_WDISP10	": 88,
    "	R_SPARC_JMP_IREL	": 248,
    "	R_SPARC_IRELATIVE	": 249,
    "	R_SPARC_GNU_VTINHERIT	": 250,
    "	R_SPARC_GNU_VTENTRY	": 251,
    "	R_SPARC_REV32	": 252,
    "	R_SPARC_NUM	": 253,

}

# typedef struct { readelf 定义
#   unsigned char	e_ident[16];		/* ELF "magic number" */
#   unsigned char	e_type[2];		/* Identifies object file type */
#   unsigned char	e_machine[2];		/* Specifies required architecture */
#   unsigned char	e_version[4];		/* Identifies object file version */
#   unsigned char	e_entry[8];		/* Entry point virtual address */
#   unsigned char	e_phoff[8];		/* Program header table file offset */
#   unsigned char	e_shoff[8];		/* Section header table file offset */
#   unsigned char	e_flags[4];		/* Processor-specific flags */
#   unsigned char	e_ehsize[2];		/* ELF header size in bytes */
#   unsigned char	e_phentsize[2];		/* Program header table entry size */
#   unsigned char	e_phnum[2];		/* Program header table entry count */
#   unsigned char	e_shentsize[2];		/* Section header table entry size */
#   unsigned char	e_shnum[2];		/* Section header table entry count */
#   unsigned char	e_shstrndx[2];		/* Section header string table index */
# } Elf64_External_Ehdr;

# /* 64-bit ELF program header.  */  readelf 定义
#
# typedef struct {
#   unsigned char	p_type[4];		/* Identifies program segment type */
#   unsigned char	p_flags[4];		/* Segment flags */
#   unsigned char	p_offset[8];		/* Segment file offset */
#   unsigned char	p_vaddr[8];		/* Segment virtual address */
#   unsigned char	p_paddr[8];		/* Segment physical address */
#   unsigned char	p_filesz[8];		/* Segment size in file */
#   unsigned char	p_memsz[8];		/* Segment size in memory */
#   unsigned char	p_align[8];		/* Segment alignment, file & memory */
# } Elf64_External_Phdr;

# typedef struct 原版定义
# {
#   Elf64_Word	p_type;			/* Segment type */
#   Elf64_Word	p_flags;		/* Segment flags */
#   Elf64_Off	p_offset;		/* Segment file offset */
#   Elf64_Addr	p_vaddr;		/* Segment virtual address */
#   Elf64_Addr	p_paddr;		/* Segment physical address */
#   Elf64_Xword	p_filesz;		/* Segment size in file */
#   Elf64_Xword	p_memsz;		/* Segment size in memory */
#   Elf64_Xword	p_align;		/* Segment alignment */
# } Elf64_Phdr;

# typedef struct  原版定义
# {
#   unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
#   Elf64_Half	e_type;			/* Object file type */
#   Elf64_Half	e_machine;		/* Architecture */
#   Elf64_Word	e_version;		/* Object file version */
#   Elf64_Addr	e_entry;		/* Entry point virtual address */
#   Elf64_Off	e_phoff;		/* Program header table file offset */
#   Elf64_Off	e_shoff;		/* Section header table file offset */
#   Elf64_Word	e_flags;		/* Processor-specific flags */
#   Elf64_Half	e_ehsize;		/* ELF header size in bytes */
#   Elf64_Half	e_phentsize;		/* Program header table entry size */
#   Elf64_Half	e_phnum;		/* Program header table entry count */
#   Elf64_Half	e_shentsize;		/* Section header table entry size */
#   Elf64_Half	e_shnum;		/* Section header table entry count */
#   Elf64_Half	e_shstrndx;		/* Section header string table index */
# } Elf64_Ehdr;

PT_LOOS = 0x60000000  # /* Start of OS-specific */
PT_LOPROC = 0x70000000  # /* Start of processor-specific */
program_types = {
    "PT_LOAD": 1,
    "PT_DYNAMIC": 2,
    "PT_INTERP": 3,
    "PT_NOTE": 4,
    "PT_SHLIB": 5,
    "PT_PHDR": 6,
    "PT_TLS": 7,
    "PT_LOOS": 0x60000000,
    "PT_GNU_EH_FRAME": 0x6474e550,
    "PT_GNU_STACK": 0x6474e551,
    "PT_GNU_RELRO": 0x6474e552,
    "PT_LOSUNW": 0x6ffffffa,
    "PT_SUNWBSS": 0x6ffffffa,
    "PT_SUNWSTACK": 0x6ffffffb,
    "PT_HISUNW": 0x6fffffff,
    "PT_HIOS": 0x6fffffff,
    "PT_LOPROC": 0x70000000,
    "PT_HIPROC": 0x7fffffff,
    "PT_MIPS_REGINFO": 0x70000000,
    "PT_MIPS_RTPROC": 0x70000001,
    "PT_MIPS_OPTIONS": 0x70000002,
    "PT_MIPS_ABIFLAGS": 0x70000003,
    "PT_HP_TLS": PT_LOOS + 0x0,
    "PT_HP_CORE_NONE         ": PT_LOOS + 0x1,
    "PT_HP_CORE_VERSION      ": PT_LOOS + 0x2,
    "PT_HP_CORE_KERNEL       ": PT_LOOS + 0x3,
    "PT_HP_CORE_COMM         ": PT_LOOS + 0x4,
    "PT_HP_CORE_PROC         ": PT_LOOS + 0x5,
    "PT_HP_CORE_LOADABLE     ": PT_LOOS + 0x6,
    "PT_HP_CORE_STACK        ": PT_LOOS + 0x7,
    "PT_HP_CORE_SHM          ": PT_LOOS + 0x8,
    "PT_HP_CORE_MMF          ": PT_LOOS + 0x9,
    "PT_HP_PARALLEL          ": PT_LOOS + 0x10,
    "PT_HP_FASTBIND          ": PT_LOOS + 0x11,
    "PT_HP_OPT_ANNOT         ": PT_LOOS + 0x12,
    "PT_HP_HSL_ANNOT         ": PT_LOOS + 0x13,
    "PT_HP_STACK             ": PT_LOOS + 0x14,
    "PT_PARISC_ARCHEXT       ": 0x70000000,
    "PT_PARISC_UNWIND        ": 0x70000001,
    "PT_ARM_EXIDX            ": PT_LOPROC + 1,  # /* ARM unwind segment.  */
    "PT_IA_64_ARCHEXT        ": PT_LOPROC + 0,  # /* arch extension bits */
    "PT_IA_64_UNWIND         ": PT_LOPROC + 1,  # /* ia64 unwind bits */
    "PT_IA_64_HP_OPT_ANOT    ": PT_LOOS + 0x12,
    "PT_IA_64_HP_HSL_ANOT    ": PT_LOOS + 0x13,
    "PT_IA_64_HP_STACK       ": PT_LOOS + 0x14,
}

program_flag = {
    "	PF_X	": 1 << 0,
    "	PF_W	": 1 << 1,
    "	PF_R	": 1 << 2,
    "	PF_MASKOS	": 0x0ff00000,
    "	PF_MASKPROC	": 0xf0000000,
}

# define PT_LOAD         1               /* Loadable program segment */
# define PT_DYNAMIC      2               /* Dynamic linking information */
# define PT_INTERP       3               /* Program interpreter */
# define PT_NOTE         4               /* Auxiliary information */
# define PT_SHLIB        5               /* Reserved */
# define PT_PHDR         6               /* Entry for header table itself */
# define PT_TLS          7               /* Thread-local storage segment */
# define PT_LOOS         0x60000000      /* Start of OS-specific */
# define PT_GNU_EH_FRAME 0x6474e550      /* GCC .eh_frame_hdr segment */
# define PT_GNU_STACK    0x6474e551      /* Indicates stack executability */
# define PT_GNU_RELRO    0x6474e552      /* Read-only after relocation */
# define PT_LOSUNW       0x6ffffffa
# define PT_SUNWBSS      0x6ffffffa      /* Sun Specific segment */
# define PT_SUNWSTACK    0x6ffffffb      /* Stack segment */
# define PT_HISUNW       0x6fffffff
# define PT_HIOS         0x6fffffff      /* End of OS-specific */
# define PT_LOPROC       0x70000000      /* Start of processor-specific */
# define PT_HIPROC       0x7fffffff      /* End of processor-specific */
# define PT_MIPS_REGINFO   0x70000000    /* Register usage information. */
# define PT_MIPS_RTPROC    0x70000001    /* Runtime procedure table. */
# define PT_MIPS_OPTIONS   0x70000002
# define PT_MIPS_ABIFLAGS  0x70000003    /* FP mode requirement. */
# define PT_HP_TLS               (PT_LOOS + 0x0)
# define PT_HP_CORE_NONE         (PT_LOOS + 0x1)
# define PT_HP_CORE_VERSION      (PT_LOOS + 0x2)
# define PT_HP_CORE_KERNEL       (PT_LOOS + 0x3)
# define PT_HP_CORE_COMM         (PT_LOOS + 0x4)
# define PT_HP_CORE_PROC         (PT_LOOS + 0x5)
# define PT_HP_CORE_LOADABLE     (PT_LOOS + 0x6)
# define PT_HP_CORE_STACK        (PT_LOOS + 0x7)
# define PT_HP_CORE_SHM          (PT_LOOS + 0x8)
# define PT_HP_CORE_MMF          (PT_LOOS + 0x9)
# define PT_HP_PARALLEL          (PT_LOOS + 0x10)
# define PT_HP_FASTBIND          (PT_LOOS + 0x11)
# define PT_HP_OPT_ANNOT         (PT_LOOS + 0x12)
# define PT_HP_HSL_ANNOT         (PT_LOOS + 0x13)
# define PT_HP_STACK             (PT_LOOS + 0x14)
# define PT_PARISC_ARCHEXT       0x70000000
# define PT_PARISC_UNWIND        0x70000001
# define PT_ARM_EXIDX            (PT_LOPROC + 1) /* ARM unwind segment.  */
# define PT_IA_64_ARCHEXT        (PT_LOPROC + 0) /* arch extension bits */
# define PT_IA_64_UNWIND         (PT_LOPROC + 1) /* ia64 unwind bits */
# define PT_IA_64_HP_OPT_ANOT    (PT_LOOS + 0x12)
# define PT_IA_64_HP_HSL_ANOT    (PT_LOOS + 0x13)
# define PT_IA_64_HP_STACK       (PT_LOOS + 0x14)
